<template>
  <el-menu :default-active="$route.path"
           :default-openeds="['1']"
           router
           class="el-menu-vertical-demo">
    <el-submenu index="1">
      <template slot="title">
        <i class="el-breadcrumb__separator el-icon-arrow-right el-icon-arrow-right-sign"></i>
        <span class="submenu-txt">工单配置</span>
      </template>
      <el-menu-item-group>
        <el-menu-item class="el-menu-show"
                      v-show="item.meta.btnAuth"
                      v-for="item in systemOptionsAuth"
                      :class="urlRoute == item.router ? 'is-active' :''"
                      :key="item.router"
                      :index="item.router">
          <span :class="urlRoute == item.router ? 'el-button--primary' : 'work-order-dot'"></span>{{item.name}}
        </el-menu-item>
        <el-menu-item class="el-menu-show"
                      v-show="btnStates[item.meta.btnName]"
                      v-for="item in systemOptions"
                      :class="urlRoute == item.router ? 'is-active' :''"
                      :key="item.router"
                      :index="item.router">
          <span :class="urlRoute == item.router ? 'el-button--primary' : 'work-order-dot'"></span>{{item.name}}
        </el-menu-item>
      </el-menu-item-group>
    </el-submenu>
  </el-menu>
</template>

<script>
export default {
  data () {
    return {
      urlRoute: '',
      fromRoute: '',
      urlOrder: '',
      btnStates:window.CONFIG.btnState,
      systemOptionsAuth:[
         {
          name: '自定义字段',
          router: '/customField',
          meta: {
            btnName: 'EWS_customField_032',
            btnAuth:true
          }
        },
        {
          name: '工单状态',
          router: '/workStatus',
          meta: {
            btnName: 'EWS_workStatus_033',
            btnAuth:true
          }
        },
        {
          name: '工单模板',
          router: '/formWork',
          meta: {
            btnName: 'EWS_formWork_034',
            btnAuth:true
          }
        },
        {
          name: '工单流程',
          router: '/workType',
          meta: {
            btnName: 'EWS_workType_035',
            btnAuth:true
          }
        }
      ],
      systemOptions: [
        {
          name: '自定义菜单',
          router: '/customMenu',
          meta: {
            btnName: 'EWS_customField_036',
          }
        },
        {
          name: '工单触发器',
          router: '/workTrigger',
          meta: {
            btnName: 'EWS_workTrigger_037',
          }
        }, {
          name: '其他参数设置',
          router: '/setParams',
          meta: {
            btnName: 'EWS_setParams_038',
          }
        }, {
          name: '通知设置',
          router: '/setNotice',
          meta: {
            btnName: 'EWS_setNotice_039',
          }
        }
      ]
    }
  },
  created () {
    var url = window.location.href
    let urls = url.split('/')
    this.urlRoute = urls[4]
  },
  watch: {// 监听路由变化
    $route (to, from) {
      this.urlRoute = to.path
      this.fromRoute = from.path
      let urlRoutes = to.path
      urlRoutes = urlRoutes.split('/')
      this.urlOrder = urlRoutes[1]
    }
  },
  mounted () {
  },
  methods: {
    systemConfigTit (params) {
      this.$store.commit('systemConfigTitFun', params)
    }
  }
}
</script>
<style scoped>
  .submenu-txt {
    font-weight: 700;
    color: #231815;
    font-size: 13px;
    font-family: Microsoft YaHei;
  }
  .el-icon-arrow-right {
    font-size: 13px;
    font-weight: 700;
  }
  .el-button--primary,.work-order-dot {
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    padding:0;
    border:none;
    margin-right: 10px;
  }
  .work-order-dot {
    background-color: #c7c7c9;
  }
  .el-menu-item.is-active {
    font-weight: bold;
  }
  >>> .el-menu-item-group__title {
    padding: 0;
  }
  .el-menu-show {
    height: 44px;
    line-height: 44px;
  }
</style>
